package cn.tedu.appointment.accounts.service.impl;

import cn.tedu.appointment.accounts.mapper.UserMapper;
import cn.tedu.appointment.accounts.pojo.dto.UserQuery;
import cn.tedu.appointment.accounts.pojo.entity.User;
import cn.tedu.appointment.accounts.pojo.vo.UserVO;
import cn.tedu.appointment.accounts.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
@Slf4j
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    @Override
    public List<UserVO> selectAll(UserQuery userQuery) {
        log.debug("查询所有用户信息{} userQuery",userQuery);
        List<UserVO> userVO = userMapper.selectAll(userQuery);
        return userVO;
    }

    // 更新用户状态(是否拉入黑名单)
    @Override
    public void updateStatus(Long id, String status) {
        log.debug("更新用户状态{} id{}",status,id);
        User user = new User();
        user.setId(id);
        user.setStatus(status);
        user.setUpdateTime(new Date());
        userMapper.update(user);
    }
// 删除用户
    @Override
    public void delete(Long id) {
        log.debug("删除用户{} id{}",id);
        userMapper.delete(id);
    }
}
